package com.krisyu.builderPattern.example.product;

import java.util.List;

/**
 * @author KrisYu
 * @date 2022/12/17
 * @description
 */
public abstract class CarModel {
    private List<String> sequence;


    protected abstract void start();
    protected abstract void alarm();
    protected abstract void engineBoom();
    protected abstract void stop();

    final public void run(){
        if(sequence != null){
            for (String func : sequence) {
                if("start".equalsIgnoreCase(func)){
                    start();
                }else if("alarm".equalsIgnoreCase(func)){
                    alarm();
                }else if("engineBoom".equalsIgnoreCase(func)){
                    engineBoom();
                }else if("stop".equalsIgnoreCase(func)){
                    stop();
                }
            }
        }
    }

    final public void setSequence(List<String> sequence){
        this.sequence = sequence;
    }

}
